<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;

use App\Models\Book;

class AdminSearchController extends Controller
{


    public function index(Request $search_text)
    {
        //显示搜索出来的图书 每页显示15个记录
        $pre_page = 15;

        //获得所有搜索出来的图书信息的数据->books数据库 按倒序
        $search_text = $search_text->input('search_text');
        $books = Book::where('book_name', 'like', '%'.trim($search_text).'%')
                        ->OrWhere('zuozhe', 'like', '%'.trim($search_text).'%')
                        ->OrWhere('isbn', 'like', '%'.trim($search_text).'%')
                        ->orderBy('book_id', 'desc')->paginate($pre_page);

        return view('admin.abooklist', compact('books'));

    }

    
}
